<template>
  <el-dialog :title="$i18n.t('mesProdOrderTraceReport.stationPassInfo')" :visible.sync="dialogVisible" width="70%">
    <ele-table
      ref="xTable"
      :getList="(data) => getList(data)"
      :operateList="operateList"
      :column="column"
      :beforeRequest="beforeRequest"
      :transFormdata="transFormdata"
      @handleOperateEvent="handleOperateEvent"
      :maxHeight="300"
    >
    </ele-table
  ></el-dialog>
</template>
<script>
import { orderTraceReportGetD } from "@/api/order/mesProdOrder";
export default {
  name: "table",
  data() {
    return {
      dialogVisible: false,
      operateList: [],
      id: "",
      column: [],
    };
  },
  methods: {
    //模拟接口请求
    async getList(data) {
      let res = await orderTraceReportGetD({ ...data, id: this.id });
      let { columnMap, recordPage } = res.data.result;
      //   this.column = [];
      let column = [];
      for (const key in columnMap) {
        column.push({ prop: key, label: columnMap[key], minWidth: 200 });
      }
      this.column = column;
      return {
        data: {
          result: {
            records: recordPage.records,
            total: recordPage.total,
          },
        },
      };
    },
    //数据结构的转化，在请求完成之后执行
    transFormdata(data) {
      console.log(111, data);
      return Promise.resolve({
        records: data.data.result.records,
        total: data.data.result.total,
      });
    },
    //列表每次请求之前都会触发，
    beforeRequest(data) {
      return { ...data };
    },
    //顶部按钮操作事件
    handleOperateEvent(data) {},
    //表格行操作事件
    rowOperate(data) {},
  },
};
</script>
